home *** CD-ROM | disk | FTP | other *** search
Text File | 2010-08-12 | 88.5 KB | 3,162 lines |
- function resetAll()
- {
- _root.gamesup = false;
- _root.aiclose = false;
- _root.iknowit = false;
- stopAllSounds();
- delete this.onEnterFrame;
- _root.g.unloadMovie();
- _root.g.removeMovieClip();
- _root.water.unloadMovie();
- _root.water.removeMovieClip();
- _root.dudes.unloadMovie();
- _root.dudes.removeMovieClip();
- _root.pw.unloadMovie();
- _root.pw.removeMovieClip();
- _root.cover.unloadMovie();
- _root.cover.removeMovieClip();
- _root.hud.unloadMovie();
- _root.hud.removeMovieClip();
- _root.bg.unloadMovie();
- _root.bg.removeMovieClip();
- _root.gameover.unloadMovie();
- _root.gameover.removeMovieClip();
- _root.gotoAndStop(3);
- }
- function chkAchieve(vin)
- {
- stopAllSounds();
- h = _root.attachMovie("gameover","gameover",888);
- var _loc2_ = false;
- if(vin == "good")
- {
- _root.fanfaresound.start();
- h.picos._visible = true;
- h.ubers._visible = false;
- if(aion)
- {
- _root.so.data.onepwins += 1;
- }
- if(!_root.aion)
- {
- _root.so.data.twopwins += 1;
- }
- if(team0.length == 1 && team1.length == 3 && !_root.so.data.onepthreeonone && aion)
- {
- _root.so.data.onepthreeonone = true;
- _loc2_ = true;
- }
- if(team0.length == 2 && team1.length == 6 && !_root.so.data.onepsixontwo && aion)
- {
- _root.so.data.onepsixontwo = true;
- _loc2_ = true;
- }
- if(team0.length == 1 && team1.length == 6 && aion)
- {
- _root.so.data.onepsixonone += 1;
- if(_root.so.data.onepsixonone == 3)
- {
- _loc2_ = true;
- }
- }
- if(_root.abletomove == false && aion)
- {
- _root.so.data.onepart += 1;
- if(_root.so.data.onepart == 1 || _root.so.data.onepart == 5)
- {
- _loc2_ = true;
- }
- }
- if(_root.cavern && !_root.so.data.onepcav)
- {
- _root.so.data.onepcav = true;
- _loc2_ = true;
- }
- if(_root.abletoswitch == false && aion)
- {
- _root.so.data.onepnoswitch += 1;
- if(_root.so.data.onepnoswitch == 2)
- {
- _loc2_ = true;
- }
- }
- if(!_root.so.data.onepgrenades && goodweaps[0] == 0 && goodweaps[2] == 0 && goodweaps[3] == 0 && goodweaps[4] == 0 && goodweaps[5] == 0 && aion)
- {
- _root.so.data.onepgrenades = true;
- _loc2_ = true;
- }
- }
- else
- {
- losesound.start();
- h.picos._visible = false;
- h.ubers._visible = true;
- _root.so.data.losses += 1;
- }
- _root.tot1ploss = _root.so.data.losses;
- _root.tot1pwins = _root.so.data.onepwins;
- var _loc4_ = 0;
- i = 0;
- while(i < _root.so.data.bgplays.length)
- {
- if(i == _root.bgid)
- {
- _root.so.data.bgplays[i] += 1;
- }
- if(_root.so.data.bgplays[i] > 0)
- {
- _loc4_ += 1;
- }
- i++;
- }
- if(_loc4_ >= _root.so.data.bgplays.length && !_root.so.data.bggotten)
- {
- _loc2_ = true;
- _root.so.data.bggotten = true;
- }
- var _loc3_ = 0;
- i = 0;
- while(i < _root.so.data.fgplays.length)
- {
- if(i == _root.fgid)
- {
- _root.so.data.fgplays[i] += 1;
- }
- if(_root.so.data.fgplays[i] > 0)
- {
- _loc3_ += 1;
- }
- i++;
- }
- if(_loc3_ >= _root.so.data.fgplays.length && !_root.so.data.fggotten)
- {
- _loc2_ = true;
- _root.so.data.fggotten = true;
- }
- if(_loc2_)
- {
- h.adv._visible = true;
- }
- else
- {
- h.adv._visible = false;
- }
- }
- function clearTel()
- {
- _root.panon = false;
- _root.airstrike = false;
- _root.teleportation = false;
- _root.teletubby.unloadMovie();
- _root.teletubby.removeMovieClip();
- }
- function flashIt()
- {
- this.attachMovie("flashthing","flashit",9999);
- }
- function chkTel()
- {
- if(_root.sel.Yvel < 1.5)
- {
- _root.clearTel();
- _root.readytoswitchweapons = false;
- _root.teletimer += 1;
- if(_root.teletimer > 10)
- {
- _root.turncv = 1;
- clearInterval(_root.teltimer);
- }
- }
- }
- function freshInst(mod, who)
- {
- k = hud.createEmptyMovieClip("inst",199);
- if(mod == 0)
- {
- i = 0;
- while(i < 2)
- {
- w = k.attachMovie("invblock","block" + i,i);
- w._x = w._width * i;
- if(i == 0)
- {
- w.holder.attachMovie("icon_switch","guts",0);
- w.nam = "\'S\'";
- }
- if(i == 1)
- {
- w.holder.attachMovie("icon_check","guts",0);
- w.nam = "SPACE";
- }
- w.amt._visible = false;
- i++;
- }
- }
- if(mod == 1)
- {
- i = 0;
- while(i < 2)
- {
- w = k.attachMovie("invblock","block" + i,i);
- w._x = w._width * i;
- if(i == 0)
- {
- w.holder.attachMovie("icon_leftright","guts",0);
- w.nam = "ARROWS";
- }
- if(i == 1)
- {
- w.holder.attachMovie("icon_aim","guts",0);
- w.nam = "SPACE";
- }
- w.amt._visible = false;
- i++;
- }
- }
- if(mod == 2)
- {
- offsetx = 0;
- i = 0;
- while(i < who.myweaps.length + 1)
- {
- w = k.attachMovie("invblock","block" + i,i);
- w._x = w._width * i - offsetx * w._width;
- if(who.myweaps[i] != -1)
- {
- if(who.myweaps[i] > 0 || i >= who.myweaps.length)
- {
- if(i < who.myweaps.length)
- {
- w.nam = i + 1;
- w.holder.attachMovie("item" + i,"guts",0);
- w.amt.amt = who.myweaps[i];
- w.amt.inf._visible = false;
- }
- else
- {
- w.holder.attachMovie("icon_esc","guts",0);
- w.amt._visible = false;
- w.nam = "\'ESC\'";
- }
- }
- else
- {
- w._visible = false;
- offsetx += 1;
- }
- }
- else
- {
- w.nam = i + 1;
- w.holder.attachMovie("item" + i,"guts",0);
- w.amt.inf._visible = true;
- w.amt.amt = "";
- }
- i++;
- }
- }
- if(mod == 3)
- {
- i = 0;
- while(i < 2)
- {
- w = k.attachMovie("invblock","block" + i,i);
- w._x = w._width * i;
- if(i == 0)
- {
- w.holder.attachMovie("icon_updown","guts",0);
- w.nam = "ARROWS";
- }
- if(i == 1)
- {
- w.holder.attachMovie("icon_power","guts",0);
- w.nam = "SPACE";
- }
- w.amt._visible = false;
- i++;
- }
- }
- if(mod == 4)
- {
- i = 0;
- while(i < 1)
- {
- w = k.attachMovie("invblock","block" + i,i);
- w._x = w._width * i;
- if(i == 0)
- {
- w.holder.attachMovie("icon_go","guts",0);
- w.nam = "SPACE";
- }
- w.amt._visible = false;
- i++;
- }
- }
- if(mod == 5)
- {
- i = 0;
- while(i < 2)
- {
- w = k.attachMovie("invblock","block" + i,i);
- w._x = w._width * i;
- if(i == 0)
- {
- w.holder.attachMovie("icon_leftright","guts",0);
- w.nam = "ARROWS";
- }
- if(i == 1)
- {
- w.holder.attachMovie("icon_go","guts",0);
- w.nam = "SPACE";
- }
- w.amt._visible = false;
- i++;
- }
- }
- k._y = -520;
- k.goal = -420;
- k._x = 350 - k._width / 2;
- k.onEnterFrame = function()
- {
- if(!_root.loadinglevel)
- {
- var _loc3_ = this.goal - this._y;
- this._y += _loc3_ / 3;
- var _loc4_ = Math.abs(_loc3_);
- if(_loc4_ <= 1)
- {
- this._y = this.goal;
- delete this.onEnterFrame;
- }
- }
- };
- }
- function clearInst()
- {
- hud.inst.onEnterFrame = function()
- {
- var _loc2_ = -550 - this._y;
- this._y += _loc2_ / 4;
- var _loc3_ = Math.abs(_loc2_);
- if(_loc3_ <= 1)
- {
- this._y += _loc2_;
- delete this.onEnterFrame;
- }
- };
- }
- function initLvl(bgcol, fgcol, inside, fgtex, bgtex)
- {
- circcount = 0;
- panspeed = 10;
- _root.grav = 0.5;
- b = _root.createEmptyMovieClip("g",1);
- mainmusic = new Sound(b);
- _root.curtrack = random(3);
- mainmusic.attachSound("bgmusic" + _root.curtrack);
- w = _root.attachMovie("waterclip","water",98);
- w._y = 470;
- _root.createEmptyMovieClip("dudes",4);
- _root.createEmptyMovieClip("pw",2);
- c = _root.createEmptyMovieClip("cover",3);
- c.beginFill(bgcol,100);
- c.moveTo(-600,-600);
- c.lineTo(3500,-600);
- c.lineTo(3500,3500);
- c.lineTo(-600,3500);
- c.endFill();
- backy = c.attachMovie("bg" + bgtex,"bg",0);
- cover.setMask(pw);
- _root.attachMovie("HUD","hud",99);
- hud._y = 426;
- updateHUDdudes(team0.length,0);
- updateHUDdudes(team1.length,1);
- e = _root.createEmptyMovieClip("bg",0);
- e.beginFill(bgcol,100);
- e.lineTo(700,0);
- e.lineTo(700,550);
- e.lineTo(0,550);
- e.endFill();
- e.attachMovie("bg" + bgtex,"bg",0);
- var _loc3_ = random(100) - 200;
- var _loc2_ = random(200) + 400;
- var _loc12_ = random(100) + 200;
- var _loc11_ = random(550);
- var _loc5_ = _loc3_ + random(150) + 400;
- var _loc10_ = _loc2_ - random(150) - 50;
- var _loc14_ = random(100) + 400;
- var _loc13_ = random(550);
- var _loc4_ = _loc5_ + random(150) + 200;
- var _loc31_ = random(550);
- var _loc20_ = random(100) + 750;
- var _loc18_ = random(550);
- var _loc9_ = _loc4_ + random(250) + 550;
- var _loc30_ = random(350);
- var _loc22_ = random(200) + 1350;
- var _loc21_ = random(350);
- var _loc8_ = _loc9_ + random(150) + 100;
- var _loc29_ = random(550);
- var _loc16_ = random(200) + 1700;
- var _loc15_ = random(550);
- var _loc7_ = _loc8_ + random(150) + 300;
- var _loc27_ = random(550);
- var _loc19_ = random(200) + 2200;
- var _loc17_ = random(550);
- var _loc6_ = _loc7_ + random(150) + 400;
- var _loc24_ = random(550);
- var _loc28_ = random(200) + 2700;
- var _loc25_ = random(550);
- var _loc26_ = _loc6_ + random(150) + 600;
- var _loc23_ = random(550) + 300;
- b.lineStyle(lineweight,0);
- b.beginFill(fgcol,100);
- b.moveTo(_loc3_,_loc2_);
- b.curveTo(_loc12_,_loc11_,_loc5_,_loc10_);
- b.curveTo(_loc14_,_loc13_,_loc4_,_loc31_);
- b.curveTo(_loc20_,_loc18_,_loc9_,_loc30_);
- b.curveTo(_loc22_,_loc21_,_loc8_,_loc29_);
- b.curveTo(_loc16_,_loc15_,_loc7_,_loc27_);
- b.curveTo(_loc19_,_loc17_,_loc6_,_loc24_);
- b.curveTo(_loc28_,_loc25_,_loc26_,_loc23_);
- b.curveTo(3800,1200,2000,1200);
- b.curveTo(-100,1200,_loc3_,_loc2_);
- b.endFill();
- tx = b.createEmptyMovieClip("texture",2);
- tx.beginFill(16777215,100);
- tx.moveTo(_loc3_,_loc2_);
- tx.curveTo(_loc12_,_loc11_,_loc5_,_loc10_);
- tx.curveTo(_loc14_,_loc13_,_loc4_,_loc31_);
- tx.curveTo(_loc20_,_loc18_,_loc9_,_loc30_);
- tx.curveTo(_loc22_,_loc21_,_loc8_,_loc29_);
- tx.curveTo(_loc16_,_loc15_,_loc7_,_loc27_);
- tx.curveTo(_loc19_,_loc17_,_loc6_,_loc24_);
- tx.curveTo(_loc28_,_loc25_,_loc26_,_loc23_);
- tx.curveTo(3800,1200,2000,1200);
- tx.curveTo(-100,1200,_loc3_,_loc2_);
- tx.cacheAsBitmap = true;
- ingrid = b.attachMovie("texture" + fgtex,"tex",1);
- ingrid.setMask(tx);
- if(inside)
- {
- _loc3_ = random(100) - 200;
- _loc2_ = random(200) - 100;
- _loc12_ = random(100) + 200;
- _loc11_ = random(550) - 300;
- _loc5_ = _loc3_ + random(150) + 400;
- _loc10_ = _loc2_ - random(150) - 150;
- _loc14_ = random(100) + 400;
- _loc13_ = random(550) - 300;
- _loc4_ = _loc5_ + random(150) + 200;
- _loc31_ = random(750) - 400;
- _loc20_ = random(100) + 750;
- _loc18_ = random(550) - 300;
- _loc9_ = _loc4_ + random(250) + 550;
- _loc30_ = random(750) - 400;
- _loc22_ = random(200) + 1350;
- _loc21_ = random(350) - 300;
- _loc8_ = _loc9_ + random(150) + 300;
- _loc29_ = random(750) - 400;
- _loc16_ = random(200) + 1700;
- _loc15_ = random(550) - 300;
- _loc7_ = _loc8_ + random(150) + 300;
- _loc27_ = random(750) - 400;
- _loc19_ = random(200) + 2200;
- _loc17_ = random(550) - 300;
- _loc6_ = _loc7_ + random(150) + 400;
- _loc24_ = random(750) - 400;
- _loc28_ = random(200) + 2700;
- _loc25_ = random(550) - 300;
- _loc26_ = _loc6_ + random(150) + 600;
- _loc23_ = random(750) - 700;
- r = b.createEmptyMovieClip("topp",-3);
- r.lineStyle(lineweight,0);
- r.beginFill(fgcol,100);
- r.moveTo(_loc3_,_loc2_);
- r.curveTo(_loc12_,_loc11_,_loc5_,_loc10_);
- r.curveTo(_loc14_,_loc13_,_loc4_,_loc31_);
- r.curveTo(_loc20_,_loc18_,_loc9_,_loc30_);
- r.curveTo(_loc22_,_loc21_,_loc8_,_loc29_);
- r.curveTo(_loc16_,_loc15_,_loc7_,_loc27_);
- r.curveTo(_loc19_,_loc17_,_loc6_,_loc24_);
- r.curveTo(_loc28_,_loc25_,_loc26_,_loc23_);
- r.curveTo(3800,-1200,2500,-1900);
- r.curveTo(-100,-1200,_loc3_,_loc2_);
- tp = b.createEmptyMovieClip("texture2",-2);
- tp.beginFill(fgcol,100);
- tp.moveTo(_loc3_,_loc2_);
- tp.curveTo(_loc12_,_loc11_,_loc5_,_loc10_);
- tp.curveTo(_loc14_,_loc13_,_loc4_,_loc31_);
- tp.curveTo(_loc20_,_loc18_,_loc9_,_loc30_);
- tp.curveTo(_loc22_,_loc21_,_loc8_,_loc29_);
- tp.curveTo(_loc16_,_loc15_,_loc7_,_loc27_);
- tp.curveTo(_loc19_,_loc17_,_loc6_,_loc24_);
- tp.curveTo(_loc28_,_loc25_,_loc26_,_loc23_);
- tp.curveTo(3800,-1200,2500,-1900);
- tp.curveTo(-100,-1200,_loc3_,_loc2_);
- tp.endFill();
- tp.cacheAsBitmap = true;
- ingrid2 = b.attachMovie("texture" + fgtex,"tex2",-1);
- ingrid2.setMask(tp);
- }
- b.cacheAsBitmap = true;
- alignAll();
- _root.attachMovie("levload","levload",9998281);
- _root.physactive = true;
- _root.loadinglevel = true;
- _root.halfcv = 0;
- _root.second = setInterval(half2,100);
- }
- function changeVol(main)
- {
- main.slider._x = main._xmouse;
- if(main.slider._x < main.thing._x + 10)
- {
- main.slider._x = main.thing._x + 10;
- }
- if(main.slider._x > main.thing._width + 10)
- {
- main.slider._x = main.thing._width + 10;
- }
- var _loc2_ = (main.slider._x - 24) / 28 * 100;
- mainmusic.setVolume(_loc2_);
- }
- function switchTracks()
- {
- if(_root.curtrack < 2)
- {
- _root.curtrack += 1;
- }
- else
- {
- _root.curtrack = 0;
- }
- mainmusic.stop();
- mainmusic = new Sound(_root.g);
- mainmusic.attachSound("bgmusic" + _root.curtrack);
- mainmusic.start(0,999);
- var _loc2_ = (hud.volcontrol.slider._x - 24) / 28 * 100;
- mainmusic.setVolume(_loc2_);
- }
- function half2()
- {
- halfcv += 1;
- if(halfcv >= 3)
- {
- if(!_root.madeteam)
- {
- team0cv = 0;
- team1cv = 0;
- masterturn = "good";
- updateHP();
- makeTeam0();
- makeTeam1();
- _root.allvirts = setInterval(getVirts,5);
- _root.g.cacheAsBitmap = true;
- clearPointers();
- showPointer();
- _root.madeteam = true;
- }
- if(halfcv > 6 && !_root.chkout)
- {
- i = 0;
- while(i < team0.length)
- {
- var yo = eval("dudes.good" + i);
- var cv = 0;
- while(r.hitTest(yo._x,yo._y,true) && cv < 900)
- {
- yo._y += 2;
- yo.virty += 2;
- yo._x += 0.5;
- yo.virtx += 0.5;
- cv += 1;
- }
- if(g.hitTest(yo.virtx,yo.virty - 15,true))
- {
- makeDivot(yo._x,yo._y + 10,random(200) + 100,yo);
- }
- i++;
- }
- i = 0;
- while(i < team1.length)
- {
- var yo = eval("dudes.bad" + i);
- var cv = 0;
- while(r.hitTest(yo._x,yo._y,true) && cv < 900)
- {
- yo._y += 2;
- yo.virty += 2;
- yo._x += 0.5;
- yo.virtx += 0.5;
- cv += 1;
- }
- if(g.hitTest(yo.virtx,yo.virty - 15,true))
- {
- makeDivot(yo._x,yo._y + 10,random(200) + 100,yo);
- }
- i++;
- }
- _root.chkout = true;
- }
- if(halfcv > 18)
- {
- _root.levload.unloadMovie();
- _root.levload.removeMovieClip();
- _root.loadinglevel = false;
- _root.selecting = true;
- halfcv = 0;
- _root.madeteam = false;
- _root.chkout = false;
- mainmusic.start(0,999);
- mainmusic.setVolume(25);
- clearInterval(_root.second);
- }
- }
- }
- function updateHP()
- {
- var team0max = 0;
- var team0total = 0;
- var team0count = team0.length;
- i = 0;
- while(i < team0.length)
- {
- var d = eval("dudes.good" + i);
- if(d.dead)
- {
- team0count -= 1;
- }
- team0max += parseInt(d.maxhp);
- team0total += parseInt(d.hp);
- i++;
- }
- hud.team0bar._xscale = team0total / _root.team0maxhp * 100;
- var team1max = 0;
- var team1total = 0;
- var team1count = team1.length;
- i = 0;
- while(i < team1.length)
- {
- var d = eval("dudes.bad" + i);
- if(d.dead)
- {
- team1count -= 1;
- }
- team1max += parseInt(d.maxhp);
- team1total += parseInt(d.hp);
- i++;
- }
- updateHUDdudes(team0count,0);
- updateHUDdudes(team1count,1);
- hud.team1bar._xscale = team1total / _root.team1maxhp * 100;
- }
- function updateHUDdudes(cv, which)
- {
- i = 0;
- while(i < 5)
- {
- if(which == 0)
- {
- var thing0 = eval("hud.g" + i);
- thing0._visible = false;
- }
- else
- {
- var thing1 = eval("hud.d" + i);
- thing1._visible = false;
- }
- i++;
- }
- i = 0;
- while(i < cv)
- {
- if(which == 0)
- {
- var thing = eval("hud.g" + i);
- }
- else
- {
- var thing = eval("hud.d" + i);
- }
- thing._visible = true;
- i++;
- }
- }
- function getTurn(switcheroo)
- {
- clearTel();
- if(switcheroo)
- {
- clearInst();
- var alldead = false;
- var dfg = 0;
- i = 0;
- while(i < team1.length)
- {
- var turd = eval("dudes.bad" + i);
- if(turd.dead)
- {
- dfg += 1;
- }
- i++;
- }
- if(dfg == team1.length)
- {
- alldead = true;
- }
- if(!alldead && aion)
- {
- _root.aiclose = false;
- _root.iknowit = false;
- }
- }
- _root.projtype = 1;
- var beenswitched = false;
- _root.beenreset = false;
- offscreen.unloadMovie();
- offscreen.removeMovieClip();
- _root.team0maxhp = 0;
- _root.team1maxhp = 0;
- var dead0cv = team0.length;
- var dead1cv = team1.length;
- d = 0;
- while(d < team0.length)
- {
- var w = eval("_root.dudes.good" + d);
- w.bar._xscale = w._xscale;
- w.bar.dabar._xscale = w.hp;
- w.hittable = true;
- if(!w.dead)
- {
- w.bar._visible = true;
- }
- else
- {
- dead0cv -= 1;
- w.guts.gotoAndStop("dead");
- w._xscale = 100;
- }
- _root.team0maxhp += parseInt(w.maxhp);
- d++;
- }
- d = 0;
- while(d < team1.length)
- {
- var w = eval("_root.dudes.bad" + d);
- w.bar._xscale = w._xscale;
- w.bar.dabar._xscale = w.hp;
- w.hittable = true;
- w.thinking._visible = false;
- if(!w.dead)
- {
- w.bar._visible = true;
- }
- else
- {
- dead1cv -= 1;
- w.guts.gotoAndStop("dead");
- w._xscale = 100;
- }
- _root.team1maxhp += parseInt(w.maxhp);
- d++;
- }
- updateHP();
- if(dead0cv == 0 && dead1cv == 0)
- {
- trace("TIE!!!!");
- hud.team0bar._xscale = 0;
- hud.team1bar._xscale = 0;
- var noloop = true;
- var vinner = "good";
- }
- else
- {
- if(dead0cv == 0)
- {
- var vinner = "bad";
- hud.team0bar._xscale = 0;
- var noloop = true;
- }
- if(dead1cv == 0)
- {
- var vinner = "good";
- hud.team1bar._xscale = 0;
- var noloop = true;
- }
- }
- if(switcheroo)
- {
- if(masterturn == "bad" && !beenswitched)
- {
- masterturn = "good";
- beenswitched = true;
- }
- if(masterturn == "good" && !beenswitched)
- {
- masterturn = "bad";
- beenswitched = true;
- }
- }
- if(masterturn == "good")
- {
- team0cv += 1;
- if(team0cv > team0.length - 1)
- {
- team0cv = 0;
- }
- var whobe = eval("dudes.good" + team0cv);
- }
- if(masterturn == "bad")
- {
- team1cv += 1;
- if(team1cv > team1.length - 1)
- {
- team1cv = 0;
- }
- var whobe = eval("dudes.bad" + team1cv);
- }
- if(!noloop)
- {
- if(!aion || _root.masterturn == "good")
- {
- freshInst(0);
- }
- if(whobe.dead)
- {
- getTurn();
- }
- else
- {
- clearInterval(_root.waitforit);
- clearInterval(_root.effectsWaiter);
- _root.turncv = _root.maxturn;
- _root.sel.guts.gotoAndStop("rest");
- _root.retreatcv = 0;
- _root.sel.retreating = false;
- _root.waitforretreat = false;
- _root.sel.aiming = false;
- _root.waiting = false;
- _root.physactive = false;
- _root.sel = whobe;
- _root.sel.retreating = false;
- _root.sel.aiming = false;
- clearPointers();
- showPointer();
- _root.selecting = true;
- if(_root.aion)
- {
- if(masterturn == "bad")
- {
- _root.aiknown = false;
- }
- }
- }
- }
- else
- {
- _root.gamesup = true;
- _root.chkAchieve(vinner);
- }
- }
- function showPointer()
- {
- _root.sel.pointer._visible = true;
- }
- function clearPointers()
- {
- d = 0;
- while(d < team0.length)
- {
- var w = eval("_root.dudes.good" + d);
- w.pointer._visible = false;
- w.aimer._visible = false;
- d++;
- }
- d = 0;
- while(d < team1.length)
- {
- var w = eval("_root.dudes.bad" + d);
- w.pointer._visible = false;
- w.aimer._visible = false;
- d++;
- }
- }
- function getNormal(who)
- {
- if(who.r == undefined)
- {
- if(who.ject)
- {
- who.r = who._height;
- }
- else
- {
- who.r = who._height / 2;
- }
- who.seg = 200;
- }
- var _loc4_ = 0;
- who.xval = 0;
- who.yval = 0;
- i = 1;
- while(i < who.seg)
- {
- var _loc3_ = who.virtx + who.r * Math.sin(i * (360 / who.seg) * 0.017453292519943295);
- var _loc2_ = who.virty - who.r * Math.cos(i * (360 / who.seg) * 0.017453292519943295);
- if(g.hitTest(_loc3_,_loc2_,true) && !cover.hitTest(_loc3_,_loc2_,true))
- {
- _loc4_ = _loc4_ + 1;
- who.xval += _loc3_;
- who.yval += _loc2_;
- }
- i++;
- }
- if(_loc4_ > 0)
- {
- who._rotation = Math.atan2(who.virtx - who.xval / _loc4_,who.virty - who.yval / _loc4_) / 0.017453292519943295 * -1 + 180;
- }
- }
- function makeTeam0()
- {
- _root.team0maxhp = 0;
- h = 0;
- while(h < team0.length)
- {
- d = dudes.attachMovie(team0[h],"good" + h,h);
- d._x = random(2300) + 150;
- d._y = 600;
- d.hittable = true;
- d.myweaps = new Array();
- i = 0;
- while(i < goodweaps.length)
- {
- d.myweaps[i] = goodweaps[i];
- i++;
- }
- var _loc3_ = new Color(d.aimer.guts.col);
- _loc3_.setRGB(9025731);
- _loc3_ = new Color(d.pointer.col);
- _loc3_.setRGB(9025731);
- _loc3_ = new Color(d.bar.dabar);
- _loc3_.setRGB(1208728);
- d.id = h;
- d.typ = "good";
- d.Yvel = 0;
- d.Xvel = 0;
- while(g.hitTest(d._x,d._y,true))
- {
- d._y -= 0.2;
- }
- d.startcv = 0;
- d.onEnterFrame = function()
- {
- phys(this);
- };
- d.speed = 2;
- h++;
- }
- _root.sel = dudes.good0;
- }
- function makeTeam1()
- {
- _root.team1maxhp = 0;
- h = 0;
- while(h < team1.length)
- {
- d = dudes.attachMovie(team1[h],"bad" + h,h + 100);
- d._x = random(2300) + 150;
- d._y = 600;
- d.id = h;
- d.thinking._visible = false;
- d.hittable = true;
- d.myweaps = new Array();
- i = 0;
- while(i < badweaps.length)
- {
- d.myweaps[i] = badweaps[i];
- i++;
- }
- var _loc3_ = new Color(d.aimer.guts.col);
- _loc3_.setRGB(16711680);
- _loc3_ = new Color(d.pointer.col);
- _loc3_.setRGB(16711680);
- _loc3_ = new Color(d.bar.dabar);
- _loc3_.setRGB(16711680);
- d.typ = "bad";
- d.Yvel = 0;
- d.Xvel = 0;
- while(g.hitTest(d._x,d._y,true))
- {
- d._y -= 0.2;
- }
- d.startcv = 0;
- d.onEnterFrame = function()
- {
- phys(this);
- };
- h++;
- }
- }
- function getVirts()
- {
- t = 0;
- while(t < team0.length)
- {
- var thing = eval("dudes.good" + t);
- thing.virtx = thing._x + g._x;
- thing.virty = thing._y + g._y;
- t++;
- }
- t = 0;
- while(t < team1.length)
- {
- var thing = eval("dudes.bad" + t);
- thing.virtx = thing._x + g._x;
- thing.virty = thing._y + g._y;
- t++;
- }
- alignAll();
- }
- function phys(who)
- {
- if(!panon && !_root.firing)
- {
- if(_root.physactive || who.startcv < 2 || _root.sel == who)
- {
- who.bounced = false;
- who.mycurx = who._x;
- who.mycury = who._y;
- who.Yvel += _root.grav;
- who.storex = who._x;
- who.storey = who._y;
- who.storevirtx = who.virtx;
- who.storevirty = who.virty;
- var _loc3_ = 0;
- if(who.jumping)
- {
- var _loc4_ = - who._rotation;
- who._rotation += _loc4_ / 2;
- }
- while(g.hitTest(who.virtx,who.virty + who.Yvel / 2,true) && !cover.hitTest(who.virtx,who.virty + who.Yvel / 2,true) && !who.bounced)
- {
- who._y -= 1;
- if(who.Yvel >= 14 && !_root.loadinglevel)
- {
- trace("OUCH FELL TOO FAR! " + who.Yvel);
- if(!who.dead)
- {
- who.guts.gotoAndStop("rest");
- getNormal(who);
- }
- who.hp -= 5;
- if(_root.sel == who)
- {
- _root.retreatcv = _root.maxretreat - 1;
- _root.turncv = 1;
- _root.getTurn(true);
- }
- }
- who.onground = true;
- who.virty -= 1;
- who.Yvel = 1;
- _loc3_ += 1;
- if(!Key.isDown(38))
- {
- who.jumping = false;
- }
- if(_loc3_ > 10 && who.startcv >= 2)
- {
- who._x = who.storex;
- who._y = who.storey - 1;
- who.virtx = who.storevirtx;
- who.virty = who.storevirty - 1;
- who.bounced = true;
- who.Xvel *= -2;
- }
- }
- while(g.hitTest(who.virtx + who._width / 4,who.virty - 25,true) && !cover.hitTest(who.virtx + who._width / 4,who.virty - 25,true) && who.startcv >= 2)
- {
- who._x -= 0.5;
- who.virtx -= 0.5;
- }
- while(g.hitTest(who.virtx - who._width / 4,who.virty - 25,true) && !cover.hitTest(who.virtx - who._width / 4,who.virty - 25,true) && who.startcv >= 2)
- {
- who._x += 0.5;
- who.virtx += 0.5;
- }
- if(who.mycurx != who.myprevx || who.mycury != who.myprevy || who.startcv < 2)
- {
- who.startcv += 1;
- getNormal(who);
- }
- lookahead2(who);
- who.myprevx = who.mycurx;
- who.myprevy = who.mycury;
- if(who._y > 588 && !_root.loadinglevel)
- {
- if(!who.drowned)
- {
- splooshsound.start();
- who.drowned = true;
- }
- who.hp -= who.hp;
- who._visible = false;
- who.dead = true;
- if(_root.sel == who)
- {
- _root.retreatcv = _root.maxretreat;
- turncv = 1;
- }
- updateHP();
- }
- if(who._x > 2900 && !_root.loadinglevel || who._x < 90 && !_root.loadinglevel)
- {
- if(!who.drowned)
- {
- splooshsound.start();
- who.drowned = true;
- }
- who.hp -= who.hp;
- who._visible = false;
- who.dead = true;
- if(_root.sel == who)
- {
- _root.retreatcv = _root.maxretreat;
- turncv = 1;
- }
- updateHP();
- }
- }
- }
- }
- function lookahead2(who)
- {
- var _loc6_ = who.virtx + who.Xvel;
- var _loc5_ = who.virty + who.Yvel;
- if(g.hitTest(_loc6_,_loc5_,true) && !cover.hitTest(_loc6_,_loc5_,true) && !who.onground)
- {
- var _loc4_ = Math.atan2(who.Yvel,who.Xvel);
- var _loc3_ = Math.cos(_loc4_);
- var _loc2_ = Math.sin(_loc4_);
- while(!g.hitTest(who.virtx,who.virty,true) || cover.hitTest(who.virtx,who.virty,true))
- {
- who._x += _loc3_;
- who.virtx += _loc3_;
- who._y += _loc2_;
- who.virty += _loc2_;
- }
- }
- else
- {
- who._y += who.Yvel;
- var _loc7_ = Math.abs(who.Xvel);
- if(_loc7_ < 1)
- {
- who.Xvel = 0;
- }
- who._x += who.Xvel;
- if(who.onground)
- {
- who.Xvel *= 0.3;
- }
- else
- {
- who.Xvel *= 0.9;
- }
- }
- }
- function alignAll()
- {
- dudes._x = g._x;
- dudes._y = g._y;
- pw._x = g._x;
- pw._y = g._y;
- cover._x = g._x;
- cover._y = g._y;
- backy._x = - g._x;
- backy._y = - g._y;
- water._x = 0;
- water._y = g._y + 560;
- }
- function centerOn(who)
- {
- var _loc4_ = 350 - who._x;
- var _loc2_ = _loc4_ - g._x;
- g._x += _loc2_ / 8;
- var _loc3_ = 225 - who._y;
- var _loc5_ = _loc3_ - g._y;
- g._y += _loc5_ / 8;
- var _loc6_ = Math.abs(_loc2_);
- lockedin = false;
- if(_loc6_ < 1)
- {
- g._x = _loc4_;
- g._y = _loc3_;
- _root.lockedin = true;
- }
- if(_root.g._x >= -120 || _root.g._x <= -2120)
- {
- _root.lockedin = true;
- }
- alignAll();
- }
- function effectsWaiter()
- {
- var rdytoroll = true;
- v = 0;
- while(v < team0.length)
- {
- var chker = eval("dudes.good" + v);
- var absy = Math.abs(chker.Yvel);
- var absx = Math.abs(chker.Xvel);
- if(absy > 1 || !chker.onground || absx > 1)
- {
- if(!_root.sel.retreating)
- {
- rdytoroll = false;
- }
- }
- v++;
- }
- v = 0;
- while(v < team1.length)
- {
- var chker = eval("dudes.bad" + v);
- var absy = Math.abs(chker.Yvel);
- var absx = Math.abs(chker.Xvel);
- if(absy > 1 || !chker.onground || absx > 1)
- {
- if(!_root.sel.retreating)
- {
- rdytoroll = false;
- }
- }
- v++;
- }
- if(rdytoroll)
- {
- v = 0;
- while(v < team0.length)
- {
- var thing = eval("dudes.good" + v);
- while(g.hitTest(thing.virtx,thing.virty,true) && !cover.hitTest(thing.virtx,thing.virty,true))
- {
- thing._y -= 0.1;
- thing.virty -= 0.1;
- }
- if(!thing.rec && thing.needtorecover && thing != _root.sel && !thing.dead)
- {
- thing.guts.gotoAndStop("recover");
- }
- v++;
- }
- v = 0;
- while(v < team1.length)
- {
- var thing = eval("dudes.bad" + v);
- while(g.hitTest(thing.virtx,thing.virty,true) && !cover.hitTest(thing.virtx,thing.virty,true))
- {
- thing._y -= 0.1;
- thing.virty -= 0.1;
- }
- if(!thing.rec && thing.needtorecover && thing != _root.sel && !thing.dead)
- {
- thing.guts.gotoAndStop("recover");
- }
- if(thing == _root.sel && _root.aion && !thing.rec && thing.needtorecover && !thing.dead)
- {
- thing.guts.gotoAndStop("recover");
- }
- v++;
- }
- var retreat = true;
- _root.waitforretreat = false;
- _root.sel.aiming = false;
- _root.sel.retreating = true;
- _root.waiting = false;
- _root.physactive = false;
- }
- if(retreat)
- {
- _root.retreatcv += 1;
- if(_root.masterturn == "good")
- {
- _root.shownum0 = Math.floor(_root.maxretreat - retreatcv);
- }
- else
- {
- _root.shownum1 = Math.floor(_root.maxretreat - retreatcv);
- if(aion && !sel.dead)
- {
- if(_root.sel._xscale == 100)
- {
- if(g.hitTest(_root.sel.virtx + 5,_root.sel.virty + 10,true) && !cover.hitTest(_root.sel.virtx + 5,_root.sel.virty + 10,true))
- {
- _root.sel.needtorecover = false;
- _root.sel.guts.gotoAndStop("walk");
- _root.sel.gx = _root.sel._x;
- if(sel.gx <= sel.px + 3 && sel.px != undefined)
- {
- _root.sel.Yvel -= _root.sel.jmpht;
- _root.sel._y -= _root.sel.jmpht;
- _root.sel.virty -= _root.sel.jmpht;
- jumpsound.start();
- }
- _root.sel.Xvel += 6;
- if(!sel.jumping)
- {
- _root.sel.px = _root.sel._x;
- }
- }
- else
- {
- _root.sel.guts.gotoAndStop("rest");
- }
- }
- if(_root.sel._xscale == -100)
- {
- if(g.hitTest(_root.sel.virtx - 5,_root.sel.virty + 10,true) && !cover.hitTest(_root.sel.virtx - 5,_root.sel.virty + 10,true))
- {
- _root.sel.needtorecover = false;
- _root.sel.guts.gotoAndStop("walk");
- _root.sel.gx = _root.sel._x;
- if(sel.gx >= sel.px - 3 && sel.px != undefined)
- {
- _root.sel.Yvel -= _root.sel.jmpht;
- _root.sel._y -= _root.sel.jmpht;
- _root.sel.virty -= _root.sel.jmpht;
- jumpsound.start();
- }
- _root.sel.Xvel -= 6;
- if(!sel.jumping)
- {
- _root.sel.px = _root.sel._x;
- }
- }
- else
- {
- _root.sel.guts.gotoAndStop("rest");
- }
- }
- }
- }
- }
- if(_root.retreatcv >= _root.maxretreat)
- {
- v = 0;
- while(v < team0.length)
- {
- var thing = eval("dudes.good" + v);
- thing.rec = false;
- thing.needtorecover = false;
- v++;
- }
- v = 0;
- while(v < team1.length)
- {
- var thing = eval("dudes.bad" + v);
- thing.rec = false;
- thing.needtorecover = false;
- v++;
- }
- if(!sel.dead)
- {
- _root.sel.guts.gotoAndStop("rest");
- }
- _root.retreatcv = 0;
- _root.sel.retreating = false;
- _root.sel.Yvel = 0;
- _root.sel.Xvel = 0;
- getNormal(_root.sel);
- clearInterval(_root.waitforit);
- clearInterval(_root.effectsWaiter);
- while(!g.hitTest(_root.sel.virtx,_root.sel.virty,true) || cover.hitTest(_root.sel.virtx,_root.sel.virty,true))
- {
- _root.sel._y += 0.5;
- _root.sel.virty += 0.5;
- }
- while(g.hitTest(_root.sel.virtx,_root.sel.virty,true) && !cover.hitTest(_root.sel.virtx,_root.sel.virty,true))
- {
- _root.sel._y -= 0.1;
- _root.sel.virty -= 0.1;
- }
- getTurn(true);
- }
- }
- function testSplode(circ)
- {
- var rad = circ._width / 2;
- var centx = circ._x + g._x;
- var centy = circ._y + g._y;
- r = 0;
- while(r < rad)
- {
- p = 1;
- while(p < 45)
- {
- var day = centy + Math.sin(p) * r;
- var dax = centx + Math.cos(p) * r;
- b = 0;
- while(b < team0.length)
- {
- var thing = eval("dudes.good" + b);
- if(thing.hitTest(dax,day,true) && !thing.beenhit)
- {
- applySplode(thing,centx,centy,dax,day,circ._width);
- }
- b++;
- }
- b = 0;
- while(b < team1.length)
- {
- var thing = eval("dudes.bad" + b);
- if(thing.hitTest(dax,day,true) && !thing.beenhit)
- {
- applySplode(thing,centx,centy,dax,day,circ._width);
- }
- b++;
- }
- p++;
- }
- r += 5;
- }
- b = 0;
- while(b < team0.length)
- {
- var thing = eval("dudes.good" + b);
- thing.beenhit = false;
- b++;
- }
- b = 0;
- while(b < team1.length)
- {
- var thing = eval("dudes.bad" + b);
- thing.beenhit = false;
- b++;
- }
- }
- function applySplode(thing, centx, centy, dax, day, powa)
- {
- thing.beenhit = true;
- if(!thing.dead && thing.hp > 0)
- {
- thing.guts.gotoAndStop("hit");
- thing.needtorecover = true;
- thing.onground = false;
- var _loc7_ = centy - day;
- var _loc8_ = centx - dax;
- if(_loc7_ == 0)
- {
- _loc7_ = -1;
- }
- var _loc14_ = Math.sqrt(_loc7_ * _loc7_ + _loc8_ * _loc8_);
- var _loc10_ = Math.atan(_loc8_ / _loc7_);
- var _loc9_ = 100 - _loc14_;
- var _loc5_ = Math.cos(_loc10_) * _loc9_ / 2.5;
- var _loc6_ = - Math.abs(Math.sin(_loc10_) * _loc9_ / 10);
- if(_loc8_ > 0)
- {
- if(_loc5_ > 0)
- {
- _loc5_ *= -1;
- }
- }
- if(projtype == 3)
- {
- _loc6_ *= 4;
- _loc5_ *= 1.5;
- }
- thing.Xvel = _loc5_;
- thing.Yvel = _loc6_;
- thing.virtx = dudes._x + thing._x;
- thing.virty = dudes._y + thing._y;
- var _loc13_ = thing.virtx + thing.Xvel * 1.5;
- var _loc12_ = thing.virty + thing.Yvel * 1.5;
- if(g.hitTest(_loc13_,_loc12_,true) && !cover.hitTest(_loc13_,_loc12_,true))
- {
- var _loc11_ = Math.atan2(thing.Yvel,thing.Xvel);
- var _loc4_ = Math.cos(_loc11_);
- var _loc3_ = Math.sin(_loc11_);
- while(!g.hitTest(thing.virtx,thing.virty,true) || cover.hitTest(thing.virtx,thing.virty,true))
- {
- thing._x += _loc4_;
- thing.virtx += _loc4_;
- thing._y += _loc3_;
- thing.virty += _loc3_;
- }
- getNormal(who);
- }
- else
- {
- thing._x += thing.Xvel;
- thing._y += thing.Yvel;
- }
- if(!_root.aion || _root.masterturn == "good")
- {
- thing.hp -= Math.floor(Math.abs(_loc5_) + Math.abs(_loc6_));
- }
- if(_root.aion && masterturn == "bad")
- {
- if(thing.typ == "good")
- {
- thing.hp -= Math.floor(Math.abs(_loc5_) + Math.abs(_loc6_)) * 2;
- }
- else
- {
- thing.hp -= Math.floor(Math.abs(_loc5_) + Math.abs(_loc6_));
- }
- }
- if(thing.hp <= 0)
- {
- thing.hp = 0;
- thing.guts.gotoAndStop("dead");
- thing._xscale = 100;
- thing.cacheAsBitmap = true;
- thing.dead = true;
- }
- if(thing == _root.sel)
- {
- thing.inv = true;
- }
- updateHP();
- }
- }
- function makeDivot(dax, day, size, who)
- {
- f = pw.attachMovie("circ","circ" + circcount,circcount);
- sp = _root.dudes.attachMovie("bigsplode","bigsplode",dudes.getNextHighestDepth());
- sp._x = dax;
- sp._y = day + size / 2.2;
- while(sp._width < size / 2)
- {
- sp._xscale += 1;
- sp._yscale = sp._xscale;
- }
- f._x = dax;
- f._y = day;
- f._width = size;
- f._height = size;
- circcount += 1;
- _root.firing = false;
- if(!_root.loadinglevel && !_root.beenreset)
- {
- var _loc3_ = who;
- _root.airtotal -= 1;
- if(!_loc3_.airstrike || _root.airtotal == 0)
- {
- _root.physactive = true;
- _root.waiting = true;
- _root.effectcv = 0;
- _root.retreatcv = 0;
- _root.testingtime = false;
- _root.waitforit = setInterval(effectsWaiter,100);
- _root.beenreset = true;
- }
- if(size > 0)
- {
- testSplode(f);
- splodesound.start();
- }
- _loc3_.unloadMovie();
- _loc3_.removeMovieClip();
- _loc3_.stopit = true;
- _loc3_.exit = true;
- delete _loc3_.onEnterFrame;
- }
- }
- function traceX()
- {
- p = 0;
- while(p < team0.length)
- {
- var thing = eval("dudes.good" + p);
- p++;
- }
- p = 0;
- while(p < team1.length)
- {
- var thing = eval("dudes.bad" + p);
- p++;
- }
- }
- function runBounce(who)
- {
- tinksound.start();
- var _loc2_ = Math.abs(who.Xvel) + Math.abs(who.Yvel) * 0.2;
- if(_loc2_ < 0.5)
- {
- who.stopit = true;
- }
- while(g.hitTest(who.virtx,who.topy,true) && !cover.hitTest(who.virtx,who.topy,true) && who.Yvel < 0)
- {
- who._y += 0.5;
- who.virty += 0.5;
- who.topy += 0.5;
- }
- while(g.hitTest(who.virtx,who.boty,true) && !cover.hitTest(who.virtx,who.boty,true) && who.Yvel > 0)
- {
- who._y -= 0.5;
- who.virty -= 0.5;
- who.boty -= 0.5;
- }
- getNormal(who);
- who._rotation -= 90;
- var _loc6_ = who._rotation;
- var _loc3_ = _loc6_ * 0.017453292519943295;
- var _loc5_ = who.Xvel * 0.3;
- var _loc4_ = 0.5;
- who.Xvel = Math.cos(_loc3_) * _loc2_ + _loc5_;
- who.Yvel = Math.sin(_loc3_) * (_loc2_ * _loc4_);
- who._x += Math.cos(_loc3_) * _loc2_ + _loc5_;
- who._y += Math.sin(_loc3_) * (_loc2_ * _loc4_);
- who.virtx += Math.cos(_loc3_) * _loc2_ + _loc5_;
- who.virty += Math.sin(_loc3_) * (_loc2_ * _loc4_);
- who.rightx += Math.cos(_loc3_) * _loc2_ + _loc5_;
- who.leftx += Math.cos(_loc3_) * _loc2_ + _loc5_;
- who.topy += Math.sin(_loc3_) * (_loc2_ * _loc4_);
- who.boty += Math.sin(_loc3_) * (_loc2_ * _loc4_);
- }
- function lookahead(who, typ, origin)
- {
- if(typ == 1)
- {
- var beensploded = false;
- var x1 = who.virtx;
- var x2 = who.virtx + who.Xvel;
- var y1 = who.virty;
- var y2 = who.virty + who.Yvel;
- var distx = x2 - x1;
- var disty = y2 - y1;
- var angle = Math.atan2(disty,distx);
- var gox = Math.cos(angle);
- var goy = Math.sin(angle);
- storex = who._x;
- storey = who._y;
- if(x1 < x2)
- {
- while(x1 < x2)
- {
- x1 += gox;
- y1 += goy;
- storex += gox;
- storey += goy;
- t = 0;
- while(t < team0.length)
- {
- var yib = eval("dudes.good" + t);
- if(yib.hittable)
- {
- if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5 || who.airstrike)
- {
- if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
- {
- who._x = yib._x;
- who._y = yib._y - yib._height / 2;
- who.virtx = yib.virtx;
- who.virty = yib.virty - yib._height / 2;
- makeDivot(who._x,who._y,who.blastradius,who);
- who.airstrike = false;
- }
- }
- }
- t++;
- }
- t = 0;
- while(t < team1.length)
- {
- var yib = eval("dudes.bad" + t);
- if(yib.hittable)
- {
- if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5 || who.airstrike)
- {
- if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
- {
- who._x = yib._x;
- who._y = yib._y - yib._height / 2;
- who.virtx = yib.virtx;
- who.virty = yib.virty - yib._height / 2;
- makeDivot(who._x,who._y,who.blastradius,who);
- who.airstrike = false;
- }
- }
- }
- t++;
- }
- }
- }
- else
- {
- while(x1 > x2)
- {
- x1 += gox;
- y1 += goy;
- storex += gox;
- storey += goy;
- t = 0;
- while(t < team0.length)
- {
- var yib = eval("dudes.good" + t);
- if(yib.hittable)
- {
- if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5 || who.airstrike)
- {
- if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
- {
- who._x = yib._x;
- who._y = yib._y - yib._height / 2;
- who.virtx = yib.virtx;
- who.virty = yib.virty - yib._height / 2;
- makeDivot(who._x,who._y,who.blastradius,who);
- who.airstrike = false;
- beensploded = true;
- }
- }
- }
- t++;
- }
- t = 0;
- while(t < team1.length)
- {
- var yib = eval("dudes.bad" + t);
- if(yib.hittable)
- {
- if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5 || who.airstrike)
- {
- if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
- {
- who._x = yib._x;
- who._y = yib._y - yib._height / 2;
- who.virtx = yib.virtx;
- who.virty = yib.virty - yib._height / 2;
- makeDivot(who._x,who._y,who.blastradius,who);
- who.airstrike = false;
- beensploded = true;
- }
- }
- }
- t++;
- }
- }
- }
- }
- var nextx = who.virtx + who.Xvel;
- var nexty = who.virty + who.Yvel;
- if(g.hitTest(nextx,nexty,true) && !cover.hitTest(nextx,nexty,true))
- {
- var rads = who._rotation * 0.017453292519943295;
- var gox = Math.cos(rads);
- var goy = Math.sin(rads);
- var cv = 0;
- while(!g.hitTest(who.virtx,who.virty,true) && cv < 400 || cover.hitTest(who.virtx,who.virty,true) && cv < 400)
- {
- cv++;
- who._x += gox;
- who.virtx += gox;
- who._y += goy;
- who.virty += goy;
- }
- if(typ == 1)
- {
- makeDivot(who._x,who._y,who.blastradius,who);
- }
- }
- else
- {
- who._x += who.Xvel;
- who.Xvel *= 0.99;
- who._y += who.Yvel;
- who.Yvel += 0.7;
- }
- }
- function cannonBall(who)
- {
- who.cv += 1;
- if(who.virty < 0 && who.virtx > 0 && who.virtx < 700)
- {
- off = _root.attachMovie("offscreen","offscreen",105);
- off._x = who.virtx;
- off._y = 50;
- off.pointer._rotation = -90;
- off.dist = Math.floor(who.virty - 50);
- }
- else if(off._x != undefined && who.virtx > 0 && who.virtx < 700)
- {
- off._visible = false;
- off.unloadMovie();
- off.removeMovieClip();
- }
- if(who.virtx < 0 || who.virtx > 700)
- {
- off = _root.attachMovie("offscreen","offscreen",105);
- if(who.virty < 430)
- {
- off._y = who.virty;
- }
- else
- {
- off._y = 430;
- }
- if(who.virtx < 0)
- {
- off._x = 50;
- off.pointer._rotation = -180;
- off.dist = Math.floor(who.virtx);
- }
- if(who.virtx > 700)
- {
- off._x = 650;
- off.dist = Math.floor(who.virtx - 700);
- }
- }
- if(who.cv == 60)
- {
- who.gotoAndStop("blink");
- }
- if(who.cv > 90)
- {
- delete who.onEnterFrame;
- off._visible = false;
- off.unloadMovie();
- off.unloadMovieClip();
- who.stopit = true;
- who.exit = true;
- makeDivot(who._x,who._y,who.blastradius,who);
- _root.physactive = true;
- _root.waiting = true;
- _root.firing = false;
- who.unloadMovie();
- who.removeMovieClip();
- }
- if(!who.stopit)
- {
- who.virtx = dudes._x + who._x;
- who.virty = dudes._y + who._y;
- who.leftx = dudes._x + who._x - who._width / 3 + who.Xvel / 2;
- who.rightx = dudes._x + who._x + who._width / 3 + who.Xvel / 2;
- who.topy = dudes._y + who._y - who._height / 3 + who.Yvel / 2;
- who.boty = dudes._y + who._y + who._height / 3 + who.Yvel / 2;
- lookahead(who,0);
- centerOn(who);
- who.angle = Math.atan2(who.Yvel,who.Xvel);
- who.finale = who.angle * 180 / 3.141592653589793;
- who._rotation = who.finale;
- if(g.hitTest(who.virtx,who.virty,true) && !cover.hitTest(who.virtx,who.virty,true) || g.hitTest(who.leftx,who.virty,true) && !cover.hitTest(who.leftx,who.virty,true) || g.hitTest(who.rightx,who.virty,true) && !cover.hitTest(who.rightx,who.virty,true) || g.hitTest(who.virtx,who.topy,true) && !cover.hitTest(who.virtx,who.topy,true) || g.hitTest(who.virtx,who.boty,true) && !cover.hitTest(who.virtx,who.boty,true))
- {
- getNormal(who);
- runBounce(who);
- }
- }
- else
- {
- who.Xvel = 0;
- who.Yvel += 0.7;
- who._y += who.Yvel;
- who.virty += who.Yvel;
- while(g.hitTest(who.virtx,who.virty,true) && !cover.hitTest(who.virtx,who.virty,true))
- {
- who._y -= 1;
- who.virty -= 1;
- }
- getNormal(who);
- }
- if(who._y > 588)
- {
- who.stopit = true;
- who.exit = true;
- _root.physactive = true;
- _root.waiting = true;
- _root.firing = false;
- makeDivot(who._x,who._y,0,who);
- off._visible = false;
- off.unloadMovie();
- off.unloadMovieClip();
- splooshsound.start();
- delete who.onEnterFrame;
- who.unloadMovie();
- who.removeMovieClip();
- }
- }
- function powerBall(who, origin)
- {
- who.cv += 1;
- if(!origin.hittable)
- {
- var _loc5_ = who._x - origin._x;
- var _loc4_ = who._y - origin._y;
- if(_loc5_ != 0 && _loc4_ != 0)
- {
- who.closeness = Math.sqrt(_loc5_ * _loc5_ + _loc4_ * _loc4_);
- }
- if(who.closeness > 75)
- {
- origin.hittable = true;
- }
- }
- if(who.virty < 0 && who.virtx > 0 && who.virtx < 700)
- {
- off = _root.attachMovie("offscreen","offscreen",105);
- off._x = who.virtx;
- off._y = 50;
- off.pointer._rotation = -90;
- off.dist = Math.floor(who.virty - 50);
- }
- else if(off._x != undefined && who.virtx > 0 && who.virtx < 700)
- {
- off._visible = false;
- off.unloadMovie();
- off.unloadMovieClip();
- }
- if(who.virtx < 0 || who.virtx > 700)
- {
- off = _root.attachMovie("offscreen","offscreen",105);
- if(who.virty < 430)
- {
- off._y = who.virty;
- }
- else
- {
- off._y = 430;
- }
- if(who.virtx < 0)
- {
- off._x = 50;
- off.pointer._rotation = -180;
- off.dist = Math.floor(who.virtx);
- }
- if(who.virtx > 700)
- {
- off._x = 650;
- off.dist = Math.floor(who.virtx - 700);
- }
- }
- if(who._y > 588)
- {
- who.stopit = true;
- who.exit = true;
- _root.physactive = true;
- _root.waiting = true;
- _root.firing = false;
- makeDivot(who._x,who._y,0,who);
- off._visible = false;
- off.unloadMovie();
- off.removeMovieClip();
- splooshsound.start();
- delete who.onEnterFrame;
- who.unloadMovie();
- who.removeMovieClip();
- }
- if(!who.stopit)
- {
- who.virtx = dudes._x + who._x;
- who.virty = dudes._y + who._y;
- who.leftx = dudes._x + who._x - who._width / 3 + who.Xvel / 2;
- who.rightx = dudes._x + who._x + who._width / 3 + who.Xvel / 2;
- who.topy = dudes._y + who._y - who._height / 3 + who.Yvel / 2;
- who.boty = dudes._y + who._y + who._height / 3 + who.Yvel / 2;
- lookahead(who,1,origin);
- centerOn(who);
- who.angle = Math.atan2(who.Yvel,who.Xvel);
- who.finale = who.angle * 180 / 3.141592653589793;
- who._rotation = who.finale;
- if(g.hitTest(who.virtx,who.virty,true) && !cover.hitTest(who.virtx,who.virty,true) || g.hitTest(who.leftx,who.virty,true) && !cover.hitTest(who.leftx,who.virty,true) || g.hitTest(who.rightx,who.virty,true) && !cover.hitTest(who.rightx,who.virty,true) || g.hitTest(who.virtx,who.topy,true) && !cover.hitTest(who.virtx,who.topy,true) || g.hitTest(who.virtx,who.boty,true) && !cover.hitTest(who.virtx,who.boty,true))
- {
- getNormal(who);
- makeDivot(who._x,who._y,who.blastradius,who);
- }
- }
- }
- function makeProjectile(who, typ)
- {
- if(typ == 0)
- {
- p = _root.dudes.attachMovie("cannonball","proj",99);
- p.bouncefactor = 3;
- p.ybounce = 0.9;
- p.cv = 0;
- p.ject = true;
- p.onEnterFrame = function()
- {
- cannonBall(this);
- };
- }
- if(typ == 3)
- {
- p = _root.dudes.attachMovie("nuke","proj",99);
- p.bouncefactor = 3;
- p.ybounce = 0.9;
- p.cv = 0;
- p.ject = true;
- p.onEnterFrame = function()
- {
- cannonBall(this);
- };
- }
- if(typ == 1)
- {
- p = _root.dudes.attachMovie("powerball","proj",99);
- p.cv = 0;
- p.ject = true;
- who.hittable = false;
- p.airstrike = false;
- _root.airstrike = false;
- p.onEnterFrame = function()
- {
- powerBall(this,who);
- };
- }
- p._x = who._x + who.aimer._x;
- p._y = who._y + who.aimer._y;
- if(who._xscale == 100)
- {
- var _loc5_ = who._rotation + who.aimer._rotation;
- }
- else
- {
- _loc5_ = who._rotation + who.aimer._rotation * -1 - 180;
- }
- var _loc4_ = _loc5_ * 0.017453292519943295;
- p.gox = Math.cos(_loc4_);
- p.goy = Math.sin(_loc4_);
- p.Xvel = p.gox * who.powa;
- p.Yvel = p.goy * who.powa;
- checkRicochet(p,true,typ,who);
- }
- function checkRicochet(who, clearem, typ, origin)
- {
- who.virtx = dudes._x + who._x;
- who.virty = dudes._y + who._y;
- var xgoal = who.virtx + who.Xvel;
- var ygoal = who.virty + who.Yvel;
- if(typ == 1)
- {
- var beensploded = false;
- var x1 = who.virtx;
- var x2 = who.virtx + who.Xvel;
- var y1 = who.virty;
- var y2 = who.virty + who.Yvel;
- var distx = x2 - x1;
- var disty = y2 - y1;
- var angle = Math.atan2(disty,distx);
- var gox = Math.cos(angle);
- var goy = Math.sin(angle);
- if(x1 < x2)
- {
- while(x1 < x2)
- {
- x1 += gox;
- y1 += goy;
- who._x += gox;
- who._y += goy;
- who.virtx += gox;
- who.virty += goy;
- t = 0;
- while(t < team0.length)
- {
- var yib = eval("dudes.good" + t);
- if(yib.hittable)
- {
- if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5)
- {
- if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
- {
- who._x = yib._x;
- who._y = yib._y - yib._height / 2;
- who.virtx = yib.virtx;
- who.virty = yib.virty - yib._height / 2;
- makeDivot(yib._x,yib._y - yib._height / 2,200,who);
- beensploded = true;
- }
- }
- }
- t++;
- }
- t = 0;
- while(t < team1.length)
- {
- var yib = eval("dudes.bad" + t);
- if(yib.hittable)
- {
- if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5)
- {
- if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
- {
- who._x = yib._x;
- who._y = yib._y - yib._height / 2;
- who.virtx = yib.virtx;
- who.virty = yib.virty - yib._height / 2;
- makeDivot(yib._x,yib._y - yib._height / 2,200,who);
- beensploded = true;
- }
- }
- }
- t++;
- }
- }
- }
- else
- {
- while(x1 > x2)
- {
- x1 += gox;
- y1 += goy;
- who._x += gox;
- who._y += goy;
- who.virtx += gox;
- who.virty += goy;
- t = 0;
- while(t < team0.length)
- {
- var yib = eval("dudes.good" + t);
- if(yib.hittable)
- {
- if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5)
- {
- if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
- {
- who._x = yib._x;
- who._y = yib._y - yib._height / 2;
- who.virtx = yib.virtx;
- who.virty = yib.virty - yib._height / 2;
- makeDivot(yib._x,yib._y - yib._height / 2,200,who);
- beensploded = true;
- }
- }
- }
- t++;
- }
- t = 0;
- while(t < team1.length)
- {
- var yib = eval("dudes.bad" + t);
- if(yib.hittable)
- {
- if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5)
- {
- if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
- {
- who._x = yib._x;
- who._y = yib._y - yib._height / 2;
- who.virtx = yib.virtx;
- who.virty = yib.virty - yib._height / 2;
- makeDivot(yib._x,yib._y - yib._height / 2,200,who);
- beensploded = true;
- }
- }
- }
- t++;
- }
- }
- }
- }
- if(g.hitTest(xgoal,ygoal,true) && !cover.hitTest(xgoal,ygoal,true) && !beensploded)
- {
- var cv = 0;
- while(!g.hitTest(who.virtx,who.virty,true) && cv < 350 || cover.hitTest(who.virtx,who.virty,true) && cv < 350)
- {
- cv++;
- who._x += who.gox;
- who.virtx += who.gox;
- who._y += who.goy;
- who.virty += who.goy;
- }
- getNormal(who);
- if(typ == 0)
- {
- runBounce(who);
- }
- if(typ == 1)
- {
- makeDivot(who._x,who._y,200,who);
- }
- }
- else
- {
- who._x += who.Xvel;
- who._y += who.Yvel;
- }
- if(clearem)
- {
- clearPointers();
- }
- }
- function controls()
- {
- if(!aion || masterturn == "good")
- {
- if(Key.isDown(27))
- {
- if(_root.sel.aiming)
- {
- _root.sel.aiming = false;
- _root.sel.aimer._visible = false;
- _root.readytoswitchweapons = false;
- _root.sel.rdy = false;
- rdytocharge = false;
- freshInst(1,sel);
- }
- }
- if(!_root.loadinglevel)
- {
- if(_root.selecting)
- {
- if(!Key.isDown(83))
- {
- sup = true;
- }
- else if(sup)
- {
- if(_root.abletoswitch)
- {
- getTurn();
- switchsound.start();
- _root.sel.guts.gotoAndStop("rest");
- }
- sup = false;
- }
- }
- if(!Key.isDown(32) && !_root.sel.retreating)
- {
- spaceup = true;
- }
- else if(spaceup)
- {
- if(!_root.sel.retreating)
- {
- if(!_root.sel.aiming && !_root.selecting)
- {
- freshInst(2,sel);
- powersound.start();
- _root.sel.aiming = true;
- if(sel.myweaps[0] == 0)
- {
- _root.projtype = 0;
- }
- _root.sel.guts.gotoAndStop("aiming");
- _root.sel.aimer._visible = true;
- _root.sel.aimer.gotoAndPlay(1);
- _root.readytoswitchweapons = true;
- _root.sel.powa = 0;
- }
- if(_root.selecting)
- {
- selsound.start();
- selsound.setVolume(30);
- freshInst(1);
- _root.selecting = false;
- _root.turncv = _root.maxturn;
- _root.testingtime = true;
- }
- }
- spaceup = false;
- }
- if(_root.sel.aiming)
- {
- if(!Key.isDown(32))
- {
- _root.sel.rdy = true;
- rdytocharge = true;
- loopedy = false;
- }
- if(Key.isDown(32) && _root.sel.rdy && !_root.teleportation && !_root.airstrike && _root.projtype != 4)
- {
- if(rdytocharge)
- {
- clearInst();
- chargesound.start();
- rdytocharge = false;
- }
- _root.readytoswitchweapons = false;
- var max = 40;
- var inc = max / 5;
- if(_root.sel.powa < max)
- {
- _root.sel.powa += 1;
- }
- if(sel.powa >= max)
- {
- if(!loopedy)
- {
- chargesound.stop();
- chargeloop.start();
- chargeloop.onSoundComplete = function()
- {
- this.start();
- };
- loopedy = true;
- }
- }
- i = 0;
- while(i < 5)
- {
- var thing = eval("_root.sel.guts.aimclip.arm1.powerthing.pow" + i);
- if(_root.sel.powa >= inc * i)
- {
- thing._visible = true;
- }
- else
- {
- thing._visible = false;
- }
- i++;
- }
- _root.sel.buildingup = true;
- }
- else if(Key.isDown(32) && !_root.sel.punching)
- {
- if(projtype == 4 && !teleportation && !airstrike)
- {
- if(sel.myweaps[3] > 0)
- {
- sel.myweaps[3] -= 1;
- }
- clearInst();
- _root.sel.punching = true;
- _root.sel.guts.gotoAndStop("punch");
- d = 0;
- while(d < team0.length)
- {
- var w = eval("_root.dudes.good" + d);
- w.bar._visible = false;
- w.pointer._visible = false;
- d++;
- }
- d = 0;
- while(d < team1.length)
- {
- var w = eval("_root.dudes.bad" + d);
- w.bar._visible = false;
- w.pointer._visible = false;
- d++;
- }
- _root.sel.aimer._visible = false;
- _root.readytoswitchweapons = false;
- _root.sel.buildingup = false;
- _root.sel.rdy = false;
- _root.waitforretreat = true;
- _root.testingtime = false;
- }
- }
- }
- if(!Key.isDown(32) && _root.sel.buildingup)
- {
- _root.readytoswitchweapons = false;
- chargesound.stop();
- chargeloop.stop();
- throwsound.start();
- if(sel.myweaps[5] > 0 && projtype == 3)
- {
- sel.myweaps[5] -= 1;
- }
- if(sel.myweaps[0] > 0 && projtype == 0)
- {
- sel.myweaps[0] -= 1;
- }
- if(sel.myweaps[1] > 0 && projtype == 1)
- {
- sel.myweaps[1] -= 1;
- }
- d = 0;
- while(d < team0.length)
- {
- var w = eval("_root.dudes.good" + d);
- w.bar._visible = false;
- d++;
- }
- d = 0;
- while(d < team1.length)
- {
- var w = eval("_root.dudes.bad" + d);
- w.bar._visible = false;
- d++;
- }
- _root.sel.buildingup = false;
- _root.sel.rdy = false;
- _root.sel.aiming = false;
- _root.waitforretreat = true;
- makeProjectile(_root.sel,_root.projtype);
- _root.sel.guts.gotoAndStop("rest");
- _root.testingtime = false;
- }
- if(!Key.isDown(80))
- {
- pup = true;
- }
- else if(pup && !_root.teleportation && !_root.airstrike)
- {
- if(!panon)
- {
- panon = true;
- _root.attachMovie("pansign","pansign",999);
- }
- else
- {
- panon = false;
- pansign.unloadMovie();
- pansign.removeMovieClip();
- }
- pup = false;
- }
- if(panon)
- {
- if(!_root.teleportation && !_root.airstrike)
- {
- if(Key.isDown(39))
- {
- g._x -= panspeed;
- }
- if(Key.isDown(37))
- {
- g._x += panspeed;
- }
- if(Key.isDown(40))
- {
- g._y -= panspeed;
- }
- if(Key.isDown(38))
- {
- g._y += panspeed;
- }
- }
- else
- {
- if(Key.isDown(39))
- {
- if(g._x > -2120 && _root.teletubby._x >= 350)
- {
- g._x -= panspeed;
- }
- else if(_root.teletubby._x < 700)
- {
- _root.teletubby._x += panspeed;
- }
- else
- {
- _root.teletubby._x = 700;
- }
- }
- if(Key.isDown(37))
- {
- if(g._x < -120 && _root.teletubby._x < 350)
- {
- g._x += panspeed;
- }
- else if(_root.teletubby._x > 0)
- {
- _root.teletubby._x -= panspeed;
- }
- else
- {
- _root.teletubby._x = 0;
- }
- }
- if(Key.isDown(40))
- {
- if(g._y > -120 && _root.teletubby._y >= 225)
- {
- g._y -= panspeed;
- }
- else if(_root.teletubby._y < 450)
- {
- _root.teletubby._y += panspeed;
- }
- else
- {
- _root.teletubby._y = 450;
- }
- }
- if(Key.isDown(38))
- {
- if(g._y < 500 && _root.teletubby._y < 225)
- {
- g._y += panspeed;
- }
- else if(_root.teletubby._y > 0)
- {
- _root.teletubby._y -= panspeed;
- }
- else
- {
- _root.teletubby._y = 0;
- }
- }
- }
- }
- else
- {
- if(!_root.selecting && !who.retreating)
- {
- if(!_root.sel.aiming)
- {
- if(_root.abletomove)
- {
- if(Key.isDown(39) && !Key.isDown(37))
- {
- _root.sel.Xvel += _root.sel.speed;
- _root.sel._xscale = 100;
- _root.sel.guts.gotoAndStop("walk");
- _root.sel.bar._xscale = _root.sel._xscale;
- }
- if(Key.isDown(37) && !Key.isDown(39))
- {
- _root.sel.Xvel -= _root.sel.speed;
- _root.sel._xscale = -100;
- _root.sel.bar._xscale = _root.sel._xscale;
- _root.sel.guts.gotoAndStop("walk");
- }
- if(!Key.isDown(37) && !Key.isDown(39))
- {
- _root.sel.guts.gotoAndStop("rest");
- }
- if(Key.isDown(38) && !_root.sel.jumping)
- {
- _root.sel.Yvel -= _root.sel.jmpht;
- _root.sel._y -= _root.sel.jmpht;
- _root.sel.virty -= _root.sel.jmpht;
- _root.sel.jumping = true;
- jumpsound.start();
- }
- }
- }
- if(_root.sel.aiming)
- {
- if(Key.isDown(39) && !Key.isDown(37))
- {
- _root.sel._xscale = 100;
- }
- if(Key.isDown(37) && !Key.isDown(39))
- {
- _root.sel._xscale = -100;
- }
- if(Key.isDown(38))
- {
- if(_root.sel.aimer._rotation > -86)
- {
- _root.sel.aimer._rotation -= 3;
- }
- }
- if(Key.isDown(40))
- {
- if(_root.sel.aimer._rotation < 86)
- {
- _root.sel.aimer._rotation += 3;
- }
- }
- }
- }
- if(!_root.firing && !_root.waiting && !_root.loadinglevel)
- {
- centerOn(_root.sel);
- }
- }
- }
- }
- else if(!_root.loadinglevel)
- {
- if(aion && !_root.gamesup)
- {
- centerOn(_root.sel);
- if(!_root.iknowit)
- {
- var maxbing = 9999999;
- i = 0;
- while(i < team1.length)
- {
- var ub = eval("dudes.bad" + i);
- if(!ub.dead)
- {
- n = 0;
- while(n < team0.length)
- {
- var tex = eval("dudes.good" + n);
- if(!tex.dead)
- {
- var clobx = ub._x - tex._x;
- var cloby = ub._y - tex._y;
- var clob = Math.abs(clobx * clobx + cloby * cloby);
- if(clob < maxbing)
- {
- maxbing = clob;
- _root.myclosedude = ub;
- }
- }
- n++;
- }
- }
- i++;
- }
- _root.iknowit = true;
- }
- if(_root.iknowit && !_root.aiclose)
- {
- if(_root.sel != _root.myclosedude)
- {
- getTurn();
- }
- else
- {
- _root.aiclose = true;
- }
- }
- if(_root.aiclose)
- {
- if(!_root.aiknown)
- {
- _root.sel.guts.gotoAndStop("rest");
- _root.sel.thinking._visible = true;
- _root.sel.pointer._visible = false;
- _root.sel._xscale = 100;
- }
- if(_root.lockedin)
- {
- if(!_root.aiknown)
- {
- var daindex = chkAIShot();
- if(daindex == undefined)
- {
- trace("I don\'t know what to do!");
- _root.getTurn(true);
- }
- else
- {
- _root.aiknown = true;
- _root.aicv = 0;
- _root.sel.thinking._visible = false;
- var startrot = -5 - _root.sel._rotation;
- _root.sel.aimer._visible = true;
- _root.sel.aimer.gotoAndPlay(1);
- _root.sel.aimer._rotation = startrot - 3 * daindex;
- if(sel.aimer._rotation < -90)
- {
- _root.sel._xscale = -100;
- sel.aimer._rotation = sel._rotation + sel.aimer._rotation * -1 - 180;
- }
- else
- {
- _root.sel._xscale = 100;
- }
- i = 0;
- while(i < team0.length)
- {
- var thing = eval("dudes.good" + i);
- thing.bar._visible = false;
- i++;
- }
- i = 0;
- while(i < team1.length)
- {
- var thing = eval("dudes.bad" + i);
- thing.bar._visible = false;
- i++;
- }
- _root.projtype = 1;
- }
- }
- }
- }
- if(aiknown)
- {
- _root.aicv += 1;
- if(_root.aicv == 30)
- {
- _root.dudes.raytrace.unloadMovie();
- _root.dudes.raytrace.removeMovieClip();
- _root.readytoswitchweapons = false;
- _root.sel.buildingup = false;
- _root.sel.rdy = false;
- _root.sel.aiming = false;
- _root.sel.powa = 34.5;
- _root.waitforretreat = true;
- makeProjectile(_root.sel,_root.projtype);
- _root.sel.guts.gotoAndStop("rest");
- _root.testingtime = false;
- }
- }
- }
- }
- }
- function testPunch(who, block)
- {
- _root.physactive = true;
- _root.waiting = true;
- _root.effectcv = 0;
- _root.retreatcv = 0;
- _root.testingtime = false;
- _root.waitforit = setInterval(effectsWaiter,100);
- _root.beenreset = true;
- i = 0;
- while(i < team0.length)
- {
- var dude = eval("dudes.good" + i);
- if(block.hitTest(dude) && dude != who)
- {
- if(dude._x < who._x)
- {
- var offset = -5;
- }
- else
- {
- var offset = 5;
- }
- applySplode(dude,who.virtx,who.virty,who.virtx + offset,who.virty + offset,150);
- pp = _root.dudes.attachMovie("punchpoof","poof",989);
- pp._x = dude._x;
- pp._y = dude._y - 45;
- pp._xscale = 105;
- pp._yscale = pp._xscale;
- }
- i++;
- }
- i = 0;
- while(i < team1.length)
- {
- var dude = eval("dudes.bad" + i);
- if(block.hitTest(dude) && dude != who)
- {
- if(dude._x < who._x)
- {
- var offset = -5;
- }
- else
- {
- var offset = 5;
- }
- applySplode(dude,who.virtx,who.virty,who.virtx + offset,who.virty,150);
- pp = _root.dudes.attachMovie("punchpoof","poof",989);
- pp._x = dude._x;
- pp._y = dude._y - 45;
- pp._xscale = 105;
- pp._yscale = pp._xscale;
- }
- i++;
- }
- }
- function chkAIShot()
- {
- _root.airstrike = false;
- var who = _root.sel;
- var rot = -5 - who._rotation;
- var cv = 0;
- r = _root.dudes.createEmptyMovieClip("raytrace",989999);
- var res = new Array();
- var rescv = 0;
- while(rot > -175 - who._rotation)
- {
- res[rescv] = new Array();
- res[rescv][0] = 0;
- res[rescv][1] = 0;
- var pow = 35;
- var curx = who._x;
- var cury = who._y - 30;
- var dangle = who._rotation + rot;
- var rads = dangle * 0.017453292519943295;
- var gox = Math.cos(rads);
- var goy = Math.sin(rads);
- var Xvel = gox * pow;
- var Yvel = goy * pow;
- _root.starconnect = false;
- f = 0;
- while(f < 115)
- {
- i = 0;
- while(i < team0.length)
- {
- var dud = eval("dudes.good" + i);
- var mydx = who._x - dud._x;
- var mydy = who._y - dud._y;
- var mydist = Math.sqrt(mydx * mydx + mydy * mydy);
- if(mydist > 100)
- {
- if(!dud.dead)
- {
- var dadistx = curx - dud._x;
- var dadisty = cury - dud._y;
- var hyp = Math.sqrt(dadistx * dadistx + dadisty * dadisty);
- if(hyp < 75)
- {
- if(_root.debug)
- {
- t = r.attachMovie("star","test",cv);
- t._x = curx;
- t._y = cury;
- }
- curx += Xvel;
- cury += Yvel;
- cv++;
- Xvel *= 0.99;
- Yvel += 0.7;
- res[rescv][1] += 1;
- _root.starconnect = true;
- var hitdude = true;
- }
- else
- {
- var hitdude = false;
- }
- }
- else
- {
- var hitdude = false;
- }
- }
- i++;
- }
- virtx = curx + _root.g._x;
- virty = cury + _root.g._y;
- if(!hitdude && !_root.starconnect)
- {
- if(_root.g.hitTest(virtx,virty,true) && !_root.cover.hitTest(virtx,virty,true))
- {
- if(_root.debug)
- {
- t = r.attachMovie("exxon","test",cv);
- t._x = curx;
- t._y = cury;
- }
- curx += Xvel;
- cury += Yvel;
- cv++;
- Xvel *= 0.99;
- Yvel += 0.7;
- res[rescv][0] += 1;
- }
- else
- {
- if(_root.debug)
- {
- t = r.attachMovie("blackdot","test",cv);
- t._x = curx;
- t._y = cury;
- }
- curx += Xvel;
- cury += Yvel;
- cv++;
- Xvel *= 0.99;
- Yvel += 0.7;
- }
- }
- f++;
- }
- rot -= 3;
- rescv += 1;
- }
- r.cacheAsBitmap = true;
- var min = 0;
- i = 0;
- while(i < res.length)
- {
- if(res[i][0] == 0)
- {
- if(res[i][1] > min)
- {
- min = res[i][1];
- var rotindex = i;
- }
- }
- i++;
- }
- if(rotindex == undefined)
- {
- var min = 0;
- i = 0;
- while(i < res.length)
- {
- if(res[i][1] > min)
- {
- min = res[i][1];
- rotindex = i;
- }
- i++;
- }
- trace("next best is: " + rotindex);
- }
- who.thinking._visible = false;
- return rotindex;
- }
- function turnTimer()
- {
- if(_root.testingtime)
- {
- _root.turncv -= 1;
- if(_root.masterturn == "good")
- {
- _root.shownum0 = Math.floor(_root.turncv);
- }
- else
- {
- _root.shownum1 = Math.floor(_root.turncv);
- }
- if(_root.turncv == 0)
- {
- chargesound.stop();
- chargeloop.stop();
- _root.sel.buildingup = false;
- _root.sel.rdy = false;
- _root.sel.aiming = false;
- _root.sel.guts.gotoAndStop("rest");
- _root.testingtime = false;
- clearTel();
- clearInst();
- if(!_root.sel.drowned)
- {
- wrongsound.start();
- }
- else
- {
- splooshsound.start();
- }
- getTurn(true);
- _root.sel.guts.gotoAndStop("rest");
- _root.testingtime = false;
- }
- }
- }
- _root.flybysound = new Sound(this);
- _root.flybysound.attachSound("flyby");
- _root.walkiesound = new Sound(this);
- _root.walkiesound.attachSound("walkietalkie");
- _root.errorsound = new Sound(this);
- _root.errorsound.attachSound("error");
- _root.fanfaresound = new Sound(this);
- _root.fanfaresound.attachSound("fanfare");
- _root.losesound = new Sound(this);
- _root.losesound.attachSound("lose");
- _root.switchsound = new Sound(this);
- _root.switchsound.attachSound("bloop");
- _root.selsound = new Sound(this);
- _root.selsound.attachSound("bleep");
- _root.airtotal = 0;
- _root.projtype = 1;
- lineweight = 10;
- _root.debug = false;
- initLvl(12307626,16711680,cavern,_root.fgid,_root.bgid);
- var keyListener = new Object();
- keyListener.onKeyDown = function()
- {
- var num = Key.getCode();
- if(_root.readytoswitchweapons)
- {
- if(num == 54)
- {
- if(sel.myweaps[5] > 0 || sel.myweaps[5] == -1)
- {
- freshInst(3);
- clearTel();
- _root.projtype = 3;
- _root.sel.guts.gotoAndStop("aiming");
- _root.sel.guts.aimclip.freshMe();
- }
- }
- if(num == 53)
- {
- if(sel.myweaps[4] > 0 || sel.myweaps[4] == -1)
- {
- freshInst(5);
- _root.sel.guts.gotoAndStop("walkie");
- _root.sel.guts.walkie.freshMe();
- _root.sel.aimer._visible = false;
- panon = true;
- t = _root.attachMovie("teletubby","teletubby",999);
- t._x = 350;
- t._y = 225;
- t.cross._visible = false;
- t.strike._visible = true;
- t.strike.origscale = t.strike._xscale;
- _root.airstrike = true;
- }
- }
- if(num == 52)
- {
- if(sel.myweaps[3] > 0 || sel.myweaps[3] == -1)
- {
- freshInst(4);
- clearTel();
- flashIt();
- _root.projtype = 4;
- sel.aimer._visible = false;
- sel.bar._visible = false;
- sel.pointer._visible = false;
- _root.sel.guts.gotoAndStop("punchcharge");
- _root.sel.guts.punchcharge.freshMe();
- }
- }
- if(num == 50)
- {
- if(sel.myweaps[1] > 0 || sel.myweaps[1] == -1)
- {
- freshInst(3);
- clearTel();
- _root.projtype = 0;
- _root.sel.guts.gotoAndStop("aiming");
- _root.sel.guts.aimclip.freshMe();
- }
- }
- if(num == 49)
- {
- if(sel.myweaps[0] > 0 || sel.myweaps[0] == -1)
- {
- freshInst(3);
- clearTel();
- _root.projtype = 1;
- _root.sel.guts.gotoAndStop("aiming");
- _root.sel.guts.aimclip.freshMe();
- _root.sel.guts.aimclip.zook.gotoAndPlay(1);
- }
- }
- if(num == 51)
- {
- if(sel.myweaps[2] > 0 || sel.myweaps[2] == -1)
- {
- freshInst(5);
- clearInterval(_root.teltimer);
- _root.sel.guts.gotoAndStop("walkie");
- _root.sel.guts.walkie.freshMe();
- _root.sel.aimer._visible = false;
- panon = true;
- t = _root.attachMovie("teletubby","teletubby",999);
- t._x = 350;
- t._y = 225;
- t.cross._visible = true;
- t.strike._visible = false;
- _root.teleportation = true;
- }
- }
- if(_root.airstrike && num == 32)
- {
- clearInst();
- walkiesound.start();
- flybysound.start();
- d = 0;
- while(d < team0.length)
- {
- var w = eval("_root.dudes.good" + d);
- w.bar._visible = false;
- w.pointer._visible = false;
- d++;
- }
- d = 0;
- while(d < team1.length)
- {
- var w = eval("_root.dudes.bad" + d);
- w.bar._visible = false;
- w.pointer._visible = false;
- d++;
- }
- if(sel.myweaps[4] > 0)
- {
- sel.myweaps[4] -= 1;
- }
- _root.sel.buildingup = false;
- _root.sel.rdy = false;
- _root.sel.aiming = false;
- _root.waitforretreat = true;
- _root.sel.guts.gotoAndStop("rest");
- _root.testingtime = false;
- _root.airtotal = 0;
- i = 0;
- while(i < 4)
- {
- m = dudes.attachMovie("angry","strike" + i,dudes.getNextHighestDepth());
- _root.airtotal += 1;
- if(teletubby.strike._xscale == teletubby.strike.origscale)
- {
- m._x = 350 - dudes._x + 75 * i + 300;
- m._y = -700 + 55 * i;
- m.Xvel = -10;
- }
- else
- {
- m._x = 350 - dudes._x - 75 * i - 300;
- m._y = -700 - 55 * i;
- m.Xvel = 10;
- }
- m.Yvel = 0;
- m.cv = 0;
- m.ject = true;
- m.airstrike = true;
- m.onEnterFrame = function()
- {
- powerBall(this,who);
- };
- i++;
- }
- clearTel();
- }
- if(_root.airstrike && num == 37)
- {
- teletubby.strike._xscale = teletubby.strike.origscale;
- }
- if(_root.airstrike && num == 39)
- {
- teletubby.strike._xscale = - teletubby.strike.origscale;
- }
- if(_root.teleportation && num == 32)
- {
- clearInst();
- flashIt();
- sel.guts.gotoAndStop("materialize");
- var who = _root.teletubby;
- who.virtx = who._x;
- who.virty = who._y;
- if(sel.myweaps[2] > 0)
- {
- sel.myweaps[2] -= 1;
- }
- if(!(_root.g.hitTest(who.virtx,who.virty,true) && !_root.cover.hitTest(who.virtx,who.virty,true)))
- {
- _root.sel._x = _root.teletubby._x - dudes._x;
- _root.sel._y = _root.teletubby._y - dudes._y;
- panon = false;
- _root.teletubby._visible = false;
- _root.teletimer = 0;
- clearInterval(_root.teltimer);
- _root.teltimer = setInterval(chkTel,100);
- }
- }
- }
- };
- Key.addListener(keyListener);
- splooshsound = new Sound(this);
- splooshsound.attachSound("sploosh");
- chargesound = new Sound(this);
- chargesound.attachSound("chargefix.wav");
- chargeloop = new Sound(this);
- chargeloop.attachSound("chargetoploop.wav");
- splodesound = new Sound(this);
- splodesound.attachSound("splosion1.wav");
- throwsound = new Sound(this);
- throwsound.attachSound("throw.wav");
- powersound = new Sound(this);
- powersound.attachSound("powerup");
- tinksound = new Sound(this);
- tinksound.attachSound("tink");
- jumpsound = new Sound(this);
- jumpsound.attachSound("varoop");
- wrongsound = new Sound(this);
- wrongsound.attachSound("wrong");
- freshInst(0);
- _root.onEnterFrame = function()
- {
- if(!_root.waitforretreat)
- {
- controls();
- }
- if(g._y < -120)
- {
- g._y = -120;
- }
- if(g._y > 500)
- {
- g._y = 500;
- }
- if(g._x > -120)
- {
- g._x = -120;
- }
- if(g._x < -2120)
- {
- g._x = -2120;
- }
- alignAll();
- turnTimer();
- };
-